package com.tv.nextin.adapter;

import java.util.ArrayList;

import com.tv.nextin.R;
import com.tv.nextin.Utils.Utils;
import com.tv.nextin.adapter.CategoryAdapter.Holder;
import com.tv.nextin.bean.Category;
import com.tv.nextin.bean.Staff;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class StaffAdapter extends ArrayAdapter<Staff>{
	
	Context context;
	ArrayList<Staff> staffs = new ArrayList<Staff>();
	
	
	public StaffAdapter(Context context, ArrayList<Staff> staffs) {
		super(context, R.layout.item_staff, staffs);
		this.context = context;
		this.staffs = staffs;
	}


	@Override
	public int getCount() {
		return staffs.size();
	}


	@Override
	public Staff getItem(int position) {
		return staffs.get(position);
	}


	@Override
	public long getItemId(int position) {
		return position;
	}


	@Override
	public View getView(int position, View v, ViewGroup parent) {
		Holder holder = null;
        
        LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
        
        if (v == null) {
            v = mInflater.inflate(R.layout.item_staff, null);
            holder = new Holder();
            holder.txtName = (TextView) v.findViewById(R.id.txt_name_staff);
            v.setTag(holder);
        } else {
            holder = (Holder) v.getTag();
        }
        
        Staff staff = staffs.get(position);
        
        holder.txtName.setText(staff.getName());
        
        holder.txtName.setTypeface(Utils.getTypefaceRegular(context));
        
        return v;
	}
	
	class Holder{
		TextView txtName;
	}
	
	

}
